<template>
  <div class="public_main">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>{{$t('sidebar.dataReport')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('newcrumbs.crumbsSev')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('totalManage.crumbsThr')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!-- -------------搜索查询栏------------------------ -->
    <search 
			:searchData="searchData" 
			@search="search" 
			@putExcel="putExcel" 
			:searchRight="true"
			:outputRight="$store.state.common.permiss.overduerate.includes('export')"
    ></search>
    <!-- -------------表单显示栏------------------------ -->
    <div class="table">
      <template>
        <el-table :data="tableData" size="small" :summary-method="getSummaries"
          show-summary>
          <el-table-column align="center" prop="strLoanTime" :label="$t('public.no58')" width="160">
            <template slot-scope="scope">
              <span v-if="scope.row.strLoanTime!==null&&scope.row.strLoanTime!==undefined&&scope.row.strLoanTime!==''">{{scope.row.strLoanTime.slice(0,10)}}</span>
              <span v-else>{{$store.state.common.nullData}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="productPeriod" :label="$t('public.no31')" min-width="68" >
          </el-table-column>
          <el-table-column align="center" prop="loanCount" :label="$t('totalManage.lendingCount')" min-width="100">
          </el-table-column>
          <el-table-column align="center" prop="loanAmount" :label="$t('totalManage.amount')" min-width="100">
            <template slot-scope="scope">
              <span v-if="scope.row.loanAmount!==null&&scope.row.loanAmount!==undefined&&scope.row.loanAmount!==''">{{$store.state.common.id_currency}}{{$store.getters.moneySplit(scope.row.loanAmount)}}{{$store.state.common.vi_currency}}</span>
              <span v-else>{{$store.state.common.nullData}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="refundCount" :label="$t('totalManage.overCount')" min-width="100">
          </el-table-column>
          <el-table-column align="center" prop="refundAmount" :label="$t('public.no65')" min-width="100">
            <template slot-scope="scope">
              <span v-if="scope.row.refundAmount!==null&&scope.row.refundAmount!==undefined&&scope.row.refundAmount!==''">{{$store.state.common.id_currency}}{{$store.getters.moneySplit(scope.row.refundAmount)}}{{$store.state.common.vi_currency}}</span>
              <span v-else>{{$store.state.common.nullData}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="moneyRate" :label="$t('totalManage.firstRate')+'('+$t('totalManage.money')+')'" min-width="100">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.moneyRate)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="countRate" :label="$t('totalManage.firstRate')+'('+$t('totalManage.order')+')'" min-width="80">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.countRate)}}</span>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>

    <!-- ------------  分页显示栏  ------------------------ -->
    <el-row type="flex" justify="end">
      <div class="pages" >
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          layout="sizes, prev, pager, next, total,->"
          :page-sizes="pagination.pageSizeOptions"
          :page-size="pagination.pageSize"
          @size-change="handleSizeChange"
          :total="pagination.total">
        </el-pagination>
      </div>
    </el-row>

    <div class="foot"></div>

  </div>
</template>
<script>
import getApp from 'src/mixins/getApp.js';//app和apk下拉搜索
import putExcel from 'src/mixins/putExcel.js';//导出excel
export default {
  name: 'overdueRate',
  mixins:[ getApp,putExcel],
  data () {
    const searchData=[
      {
        type: 'rangePicker',
        label: 'totalManage.timeSelect',
        attr: 'searchTime',
        value: [],
      },{
        type: 'input',
        label: 'public.no25',
        attr: 'period',
        value: ''
      },{
        type: 'select',
        attr: 'userStatus',
        label: 'add.no86',
        option: this.$store.state.options.userType_option,
        value: '',
        langFlag: true,
      },{
        type: 'select',
        attr: 'appName',
        label: 'public.appName',
        option: [],
        value: '',
        langFlag: false,
      },{
        type: 'select',
        attr: 'appPackage',
        label: 'public.appPackage',
        option: [],
        value: '',
        langFlag: false,
      }
    ]
    return {
      flag: true,
      pagination: {
        pageSize: global.config.pageSize,
        pageSizeOptions: global.config.pageSizeOptions,
        current: 1,
        total: 0,
      },
      searchTime: [],
      // 用户查询信息数据对应字段
      formInline: {},
      // 当前页下标
      // 用户信息数据模拟
      tableData:[],
      tableData1:[],
      searchData:searchData,
      rowStyle:{
        backgroundColor:'rgb(241,241,241)'
      },
      putExcelUrl:this.$action.statistic_overdueExport
    }
  },
  methods: {
    handleSizeChange (val) {// 每页条数变化时操作
      this.pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChange (val) { // 分页按钮点击操作
      this.pagination.current = val;
      this.getTableData();
    },
    getTableData () { // 获取首逾率列表
      let option = {
        pageNum:this.pagination.current,
        pageSize:this.pagination.pageSize,
        param: {
          ...this.formInline
        }       
      }
      this.$axios.post(this.$action.statistic_overdueList,option).then(res=>{
        this.flag = true;
        if(res.code==200){
          this.tableData = res.data.list.list;
          this.tableData1 = res.data.count;
          this.pagination.total = res.data.list.total;
        }
      })
    },
    search (search) { // 点击查询按钮
      this.formInline = {
        period:search.period,
        userStatus:search.userStatus,
        dayBegin:search.searchTime?search.searchTime[0]:'',
        dayEnd:search.searchTime?search.searchTime[1]:'',
        appName:search.appName,
        appPackage:search.appPackage
      };
      if (this.flag) {
        this.pagination.currentPage = 1;
        this.flag = false;
        this.getTableData();
      }
    },
    getSummaries() {// 总和
      let sums = [
          this.$t('public.addTotal'),
          '-',
          this.tableData1.loanCount,
          this.$store.getters.moneySplit(this.tableData1.loanAmount),
          this.tableData1.refundCount,
          this.$store.getters.moneySplit(this.tableData1.refundAmount),
          this.$store.getters.twoPoint(this.tableData1.moneyRate),
          this.$store.getters.twoPoint(this.tableData1.countRate),
        ]
      return sums;
    }
  },
  mounted () {
    this.getApp().then(app=>{
      this.searchData[3].option=app.appName;
      this.searchData[4].option=app.appPackage;
    })
    this.getTableData();
  }
}
</script>
<style scoped lang="scss">

</style>
